/*----------------------------------------\ | Move cursor to outside of the current word table; | |-------------------------------------------| |--------------------------------------------------------------------| |--------------------------| | No arguemnt is needed; | | wordref: word reference; not necessary; default is "wordsys"; | |----------------------------| |--------------------------------------------------------------------| |---------------------------------------| | Example: %endtable; | | Usage: %endtable(nlines, wordref); | \----------------------------------------*/ %macro endtable/parmbuff; /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 6-6-2001 8:40pm; | | Purpose: Move cursor to outside of the | | current word table; | \--------------------------------------------*/ %local nlines wordref _endtabrx_ _xendtaboldstr_ _xendtabnewstr_ _xendtabpos_ wordref wsid numsid rc _endtabnewstr_ _xendtabvar_ _xendtabvarcnt_ _endtabt_ _endtabtcnt_; %let nlines=; %let wordref=; %if (%quote(&syspbuff) ne) %then %do; %let syspbuff=%sysfunc(translate(%quote(%substr(%quote(%trim(%quote(%left(%quote(&syspbuff))))), 2, %eval(%length(%trim(%quote(%left(%quote(&syspbuff)))))-2))), %str(%'), %str(%"))); %let _endtabrx_=%sysfunc(rxparse($(1))); %let _xendtabpos_=0; %let _xendtablen_=0; %let _xendtaboldstr_=; %let _xendtabnewstr_=; %do %while( %sysfunc(rxmatch(&_endtabrx_, %quote(&syspbuff))) ); %syscall rxsubstr(_endtabrx_, syspbuff, _xendtabpos_, _xendtablen_); %let _xendtaboldstr_=%quote(%substr(%quote(&syspbuff), &_xendtabpos_, &_xendtablen_)); %let _xendtabnewstr_=%quote(%sysfunc(translate(%quote(&_xendtaboldstr_), À, %quote(%(), Á, %quote(%)), ´, %quote(,), ®, %quote( )))); %let syspbuff=%sysfunc(tranwrd(%quote(&syspbuff), %quote(&_xendtaboldstr_), %quote(&_xendtabnewstr_))); %let _xendtabpos_=0; %let _xendtablen_=0; %let _xendtaboldstr_=; %let _xendtabnewstr_=; %end; %let _endtabnewstr_=&syspbuff; %local _xendtabvarcnt_ _xendtabvar_; %let _xendtabvarcnt_=0; %do %while(%length(%qscan(%nrbquote(&_endtabnewstr_), %eval(&_xendtabvarcnt_+1), %nrbquote(,)))); %let _xendtabvarcnt_=%eval(&_xendtabvarcnt_+1); %let _xendtabvar_=%nrbquote(%qscan(%nrbquote(&_endtabnewstr_), &_xendtabvarcnt_, %nrbquote(,))); %let _xendtabvar_=%sysfunc(translate(%quote(&_xendtabvar_), '(', 'À', ')', 'Á', ',', '´', ' ', '®')); %let _xendtabx2_=%trim(%left(%qscan(%quote(&_xendtabvar_), 1, %str(=)))); %let _xendtabx3_=%substr(%quote(&_xendtabvar_), %eval(%index(%quote(&_xendtabvar_),%str(=))+1), %eval(%length(&_xendtabvar_)-%index(%quote(&_xendtabvar_),%str(=)))); %if (not %index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_xendtabvar_))))), %str(=))) %then %do; %if (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_xendtabx2_))))), %str(%()) eq 1) and (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(%sysfunc(reverse(&_xendtabx2_))))))), %str(%))) eq 1) %then %let _xendtabx3_=%substr(%quote(%trim(%quote(%left(%quote(&_xendtabx2_))))), 2, %eval(%length(%trim(%quote(%left(%quote(&_xendtabx2_)))))-2)); %if (not %sysfunc(rxmatch(%sysfunc(rxparse($d)),&_xendtabx3_))) %then %do; %let _endtabtcnt_=&_xendtabvarcnt_; %if (%quote(&_endtabtcnt_) = %quote(1)) %then %let nlines=&_xendtabx3_; %else %if (%quote(&_endtabtcnt_) = %quote(2)) %then %let wordref=&_xendtabx3_; %end; %else %if (%sysfunc(rxmatch(%sysfunc(rxparse($d)),&_xendtabx3_))) %then %let nlines=&_xendtabx3_; %else %do; %put ==> Alert! In correct Input!; %goto finish; %end; %end; %else %if (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_xendtabx3_))))), %str(%()) eq 1) and (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(%sysfunc(reverse(&_xendtabx3_))))))), %str(%))) eq 1) and (%index(%nrbquote(upcase(%nrbquote(%sysfunc(compress(%nrbquote(&_xendtabx2_)))))), WHERE=) le 1) %then %let &_xendtabx2_=%substr(%quote(%trim(%quote(%left(%quote(&_xendtabx3_))))), 2, %eval(%length(%trim(%quote(%left(%quote(&_xendtabx3_)))))-2)); %else %let &_xendtabx2_=&_xendtabx3_; %end; %end; %if (%quote(&nlines) eq) %then %let nlines=0; %else %if (%chk_type(&nlines) ne 1) %then %let nlines=0; %if (%quote(&wordref) eq) %then %let wordref=wordsys; %if (%quote(&wordref) ne ) %then %let wsid=%sysfunc(fopen(&wordref,o,132,e)); %if &wsid %then %do; %let rc=%sysfunc(fclose(&wsid)); %if (%sysfunc(rxmatch(%sysfunc(rxparse($d)),&nlines))) and (not %sysfunc(rxmatch(%sysfunc(rxparse($a)),&nlines))) %then %do; data _null_; file &wordref lrecl=2000; put '[TableSelectTable]'; put "[LineDown 1]"; %if (&nlines > 0) %then %do; %do _i_=1 %to &nlines; put '[InsertPara]'; %end; %end; run; %end; %end; %else %do; %put ==> Alert! Incorrect window reference "&wordref", or window "&wordref" isn%str(%')t open.; %end; %finish: %mend endtable;